const {Controller} = require('egg');

class UserController extends Controller{
    async index(){
        let {ctx,service} = this;
        let {pagenum=1,limit=5} = ctx.query;
        console.log(ctx.params);
        try{
            let startIndex = (pagenum - 1)*limit;
            let list = await service.user.index(startIndex,limit);
            ctx.body = {
                code:1,
                data:list
            }
        }catch(e){
            ctx.body = {
                code:0,
                msg:e
            }
        }
    }

    async add(){
        let {ctx} = this;
        //添加
        let {username,password} = ctx.request.body;
        console.log(username,password);
        ctx.body = 'post'
    }
}

module.exports = UserController